<?php
	require_once   'PHPUnit/Framework.php';
	require_once   'TVB/PWORKS/util/CommonUtil.class.php';
	require_once   'TVB/PWORKS/util/FailTestUtil.class.php';
class ChapterUpdateActionTest extends PHPUnit_Framework_TestCase
{

	protected function setUp()
	{
		$this->url = "http://pdes.tvb.com/update_chapter.html?act=edit&ut=true";
	}

	protected function tearDown()
	{
		$this->url = NULL;
	}

	public function testSuccess()
    {
	
			$success_data = array(
			 //-- add record{{{
            'programme_id' => 187,
            'id' => 'new',
            'episode_id' => 162,
            'video_id' => 638,
            'new_video_id' => '',
            'in_time[0][0]' => '11',
            'in_time[1][0]' => '12',
            'in_time[2][0]' => '13',
		    'out_time[0][0]' => '21',
            'out_time[1][0]' => '22',
            'out_time[2][0]' => '23',
            'ii_id' => '',
            'thumbnail_url' => '',
            'source_url' => '',
            'location' => '',
            'highlighted_cast_roles' => '',
            'casts' => '',
            'tags' => '',
            'infos' => '',
            'status' => 1,
            'created_at' => date("Y-m-d H:i:s"),
            'created_by' => 'enoch.liu@tvb.com',
            'modified_at' =>date("Y-m-d H:i:s"),
            'modified_by' => 'enoch.liu@tvb.com',
            'title' => 'enoch@tvb.com',
            'title_en' => 'enoch@tvb.com',
            'concurrent_time' => json_encode(array())
            //}}}
		    );

		$ret = CommonUtil::curl_test($this->url,$success_data);
		$real_data = json_decode($ret);
		$err_num = count($real_data);
		if ($err_num == 0)
		{
			echo "ChapterUpdateActionTest pass!\n";
		}

		$this->assertEquals($err_num, 0); 	
	}

	public function testFailed(){

		$success_data = array(
			//-- add record{{{
			'programme_id' => 'enoch',
            'id' => 'new0',
            'episode_id' => '2',
            'video_id' =>10,
            'new_video_id' => '',
            'in_time[0]' => '11',
            'in_time[1]' => '12',
            'in_time[2]' => '13',
		    'out_time[0]' => '21',
            'out_time[1]' => '22',
            'out_time[2]' => '23',
            'ii_id' => '',
            'thumbnail_url' => '',
            'source_url' => '',
            'location' => '',
            'highlighted_cast_roles' => '',
            'casts' => '',
            'tags' => '',
            'infos' => '',
            'status' => 1,
            'created_at' => date("Y-m-d H:i:s"),
            'created_by' => 'enoch.liu@tvb.com',
            'modified_at' =>date("Y-m-d H:i:s"),
            'modified_by' => 'enoch.liu@tvb.com',
            'title' => 'enoch@tvb.com',
            'title_en' => 'enoch@tvb.com',
            'concurrent_time' => json_encode(array(date("Y-m-d H:i:s"))),
			//}}}
		);

		$ret = CommonUtil::curl_test($this->url,$success_data);
		$real_data = json_decode($ret);

		$err_num = count($real_data);
		if ($err_num > 0)
		{
			echo "ChapterUpdateActionTest failed!";
		}

		$this->assertEquals($err_num , 0); 	
    }
 
}

$suite = new PHPUnit_Framework_TestSuite('EpisodeUpdateActionTest');

// Run the tests
//$object = $suite->run();

?>


